$(document).ready(function(){
	
	$(".settingsTab").click(function(){
	
		$("#settingsTabContent").html("");
	
		allSettingsTabsClosed();
		$(this).parent().addClass("tabOpen");
		
		//HIDE CONTENT
		
		
		$("#loadingTab").show();
		$("#homeTabContent").hide();
		
		var tabClass = $(this).text().replace(" ", "");
		
		var delay = function() { displaySettingsTabContent(tabClass); };
			
		setTimeout(delay, 800);
	});
	
	function allSettingsTabsClosed()
	{
		$("#settingsTabs > span").removeClass("tabOpen");
	}
	
});


function displaySettingsTabContent(tabClass)
{
	$.ajax({
		type: "POST",
		url: "php/ajax/settings/tabContent.php",
		data: "t=" + tabClass.toLowerCase(),
		success: function(obj)
		{
			
			//SHOW CONTENT
			$("#settingsTabContent").html(obj);
			
			
			$("#loadingTab").hide();
			$("#settingsTabContent").show();
			
			//MAKE SIDEBAR SAME SIZE AS PAGE, IF PAGE IS LARGER
			$("#sidebar").css('height', 597);
			
			var sideBarHeight = parseInt($("#sidebar").outerHeight(true));
			var pageHeight = parseInt($("#page").outerHeight(true));
			
			if(sideBarHeight < (pageHeight - 58))
			{
				$("#sidebar").css('height', pageHeight);
			}
		}
	});
}

